﻿<html xmlns:th="http://www.thymeleaf.org">
<head>
    <!--资源获取-->
    <base th:href="|${#request.getContextPath()}/|">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="static/lib/html5shiv.js"></script>
    <script type="text/javascript" src="static/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="static/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--layui-->
    <link rel="stylesheet" type="text/css" href="static/layui/css/layui.css"/>
    <script type="text/javascript" src="static/layui/layui.js"></script>
    <title>资讯列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页
    <span class="c-gray en">&gt;</span>
    模拟投资
    <span class="c-gray en">&gt;</span>
    我的投资
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    <!--收藏-->
    <a id="djsc" class="btn btn-success radius r " style="line-height:1.6em;margin-top:3px" href="javascript:;"
       title="收藏">
        <i id="sc" class=" Hui-iconfont">&#xe69d;</i>
        <i id="qxsc" class=" Hui-iconfont">&#xe69e;</i></a>
    <!--收藏-->
</nav>
<div class="page-container">
    <div>
        <fieldset class="layui-elem-field">
            <legend>搜索</legend>
            <div class="layui-field-box">
                <div class="layui-inline">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="startTime" name="startTime" placeholder="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">结束时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="endTime" name="endTime" placeholder="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">搜索：</label>
                    <div class="layui-inline">
                        <input class="layui-input" name="id" id="totle" autocomplete="off">
                    </div>
                </div>
                <div class="layui-inline" style="float: right;">
                    <div class="layui-inline">
                        <button id="selectMyIn" class="layui-btn" data-type="reload">搜索</button>
                    </div>
                </div>
            </div>

        </fieldset>
    </div>
    <table class="layui-hide" id="zxtz" lay-filter="zxtz"></table>

    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
            <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
        </div>
    </script>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">详细</a>
    </script>


    <script type="text/javascript" src="static/lib/jquery/1.9.1/jquery.min.js"></script>

    <script type="text/javascript" src="static/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="static/lib/laypage/1.2/laypage.js"></script>
    <script>
        /*时间选择*/
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            //常规用法
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
        });
        /*收藏按钮*/
        var ejhref = "Investment/MyInvestment";//收藏路径
        $.ajax({
            url: "CollectionPage?page=" + ejhref,
            async: false,
            type: "GET",
            success: function (datas) {
                if (datas == "sc") {

                    $("#qxsc").addClass("layui-hide");
                    $("#sc").addClass("layui-show");

                } else {
                    $("#sc").addClass("layui-hide");
                    $("#qxsc").addClass("layui-show");
                }
            }
        })
        $("#djsc").on("click", function () {

            $.ajax({
                url: "CollectionNewPage",
                type: "POST",
                data: {
                    "page": ejhref,
                    "pageName": "我的投资"//收藏名字
                },
                success: function (regas) {
                    if (regas != "sc") {

                        $("#qxsc").attr("class", "Hui-iconfont layui-hide");
                        $("#sc").attr("class", "Hui-iconfont layui-show");

                    } else {
                        $("#sc").attr("class", "Hui-iconfont layui-hide");
                        $("#qxsc").attr("class", "Hui-iconfont layui-show");
                    }

                }
            })

        })
        /*收藏按钮*/


        /*时间转换*/
        function GetNumberOfDays(date1, date2) {//获得天数
            //date1：开始日期，date2结束日期
            var a1 = Date.parse(new Date(date1));
            var a2 = Date.parse(new Date(date2));
            var day = parseInt((a2 - date1) / (1000 * 60 * 60 * 24));//核心：时间戳相减，然后除以天数
            return day
        };
        /*表格*/
        layui.use('table', function () {
            var table = layui.table;
            var tableIns = table.render({
                elem: '#zxtz'
                , url: '/Investment/SelectMyInvestment'
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print',]
                , title: '最新投资'
                , cols: [
                    [
                        {type: 'checkbox', fixed: 'left'}
                        ,{ field: 'lx', title: '类型'}
                        , {
                        field: 'totle', title: '主题', width: 420, templet(res) {
                            return '<em title=\"' + res.remarks + '">' + res.totle + '</em>';
                        }
                    }
                        , {field: 'startTime', title: '开始时间', width: 200, sort: true}
                        , {field: 'endTime', title: '结束时间', width: 200, sort: true}
                        , {
                        field: 'SurplusTime', title: '剩余时间', width: 100, sort: true, templet: function (res) {
                            var dates = GetNumberOfDays(Date.now(), res.endTime);
                            if (dates >= 0) {
                                return '<em>' + dates + '</em>'
                            } else {
                                return '<em>已结束</em>'
                            }

                        }
                    }
                        , {
                        field: 'amount', title: '金额', sort: true, width: 150, templet: function (res) {
                            if (res.zh.amount != null) {
                                return '<em>' + res.zh.amount + '</em>';
                            } else
                                return '<em><a href="/Investment/NewUserZh?zqId=' + res.zqId + '&uId=' + [[${session.session_user.uId}]] + '" id="canyu"> ' + '点击参与' + '</a></em>'
                        }
                    }
                        , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 100}
                    ]
                ]
                , page: true
            });

            /*表格重载*/
            $('#selectMyIn').on('click', function () {
                function datess(res) {
                    if (res == "") {
                        return "";
                    } else {
                        return new Date(res);
                    }
                };
                var startTime = $('#startTime').val() ==""?"1999-01-01":$('#startTime').val();
                var endTime = $('#endTime').val() == "" ? "2999-12-31" : $('#endTime').val();
                console.log(startTime);
                console.log(endTime);
                var totle = $('#totle').val();


                tableIns.reload({
                    url: '/Investment/SelectMyInvestment',
                    page: {curr: 1},
                    where: {
                        "startTime": startTime,
                        "endTime": endTime,
                        "totle": totle
                    }

                })
            })


            //头工具栏事件
            table.on('toolbar(zxtz)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'getCheckData':
                        var data = checkStatus.data;
                        layer.alert(JSON.stringify(data));
                        break;
                    case 'getCheckLength':
                        var data = checkStatus.data;
                        layer.msg('选中了：' + data.length + ' 个');
                        break;
                    case 'isAll':
                        layer.msg(checkStatus.isAll ? '全选' : '未全选');
                        break;


                }
                ;
            });

            //监听行工具事件
            table.on('tool(zxtz)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                console.log(obj);
                if (obj.event === 'edit') {
                    layer.open({
                        type: 2,
                        title: '我的投资',
                        area: ['90%', '90%'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: 'TouZi/TzmxHtml?zqId='+data.zqId+'&uId=[[${session.session_user.uId}]]'
                    })
                }
            });
        });
    </script>

    <script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="static/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
    <script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="static/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
    <script type="text/javascript">


    </script>
</div>
</body>
</html>
